package com.bpr.webservice.domain.dto;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;

import com.bpr.webservice.domain.Users;

public class UserPageDto implements Page<UserDto> {
	
	private Page<Users> searchResult;
	
	public UserPageDto(Page<Users> usersPageResult){
		this.searchResult = usersPageResult;
	}

	@Override
	public List<UserDto> getContent() {
		List<UserDto> contents = new ArrayList<UserDto>();
		UserDto dto = null;
		for (Users user:searchResult.getContent()){
			dto = new UserDto();
			dto.constructDto(user);
			contents.add(dto);
		}
		return contents;
	}

	@Override
	public int getNumber() {
		return searchResult.getNumber();
	}

	@Override
	public int getNumberOfElements() {
		return searchResult.getNumberOfElements();
	}

	@Override
	public int getSize() {
		return searchResult.getSize();
	}

	@Override
	public Sort getSort() {
		return searchResult.getSort();
	}

	@Override
	public long getTotalElements() {
		return searchResult.getTotalElements();
	}

	@Override
	public int getTotalPages() {
		return searchResult.getTotalPages();
	}

	@Override
	public boolean hasContent() {
		return searchResult.hasContent();
	}

	@Override
	public boolean hasNextPage() {
		return searchResult.hasNextPage();
	}

	@Override
	public boolean hasPreviousPage() {
		return searchResult.hasPreviousPage();
	}

	@Override
	public boolean isFirstPage() {
		return searchResult.isFirstPage();
	}

	@Override
	public boolean isLastPage() {
		return searchResult.isLastPage();
	}

	@Override
	public Iterator<UserDto> iterator() {
		List<UserDto> contents = getContent();
		return contents.iterator();
	}

}
